home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2510.ZIP / TRSOURCE.EXE / ATLAST.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  1KB  |  34 lines

  1. /*********
  2. * Atlast.c by Leonard Zerman
  3. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  4. *
  5. * Syntax: ATLAST( <expC>, <expC> )
  6. * Return: The last position of a character found in a string. 
  7. * Note  : Returns 0 if not found, -1 if error.
  8. ********/
  9.  
  10. #include "trlib.h"
  11.  
  12. TRTYPE atlast()                          /* declare the atlast function */
  13. {  
  14.     char *instr;                    /* a pointer to the passed string */ 
  15.     char *c;                     /* a pointer to the char to be found */               
  16.     int  i;     
  17.  
  18.     if (PCOUNT ==2 && ISCHAR(1) && ISCHAR(2))                         
  19.     {                  
  20.         c     = _parc(1);
  21.         instr = _parc(2);              /* assign the address to instr */  
  22.     }
  23.     else                                     
  24.     {
  25.          _retni(ERRORNEG);                   /* return a syntax error */      
  26.          return;                               /* return from program */     
  27.     }
  28.  
  29.     for (i = _tr_strlen(instr); instr[i] != *c && i >= 0 ; i--)    
  30.         ;                        /* empty loop checking for condition */               
  31.     _retni( ++i );
  32. }
  33.  
  34.